package T01_test_all.test1;

import java.util.Random;

public class test03_Luckydraw {
    public static void main(String[] args) {
        int[] arr = {1, 888, 1000, 520, 9999};
        int[] arr2 = new int[arr.length];
        Random r = new Random();
        for (int i = 0; i < 5; ) {
            int randomIndex = r.nextInt(arr.length);
            int prize = arr[randomIndex];
            boolean flag = contains(arr2,prize);
            if(!flag){
                arr2[i] = prize;
                i++;
            }
        }
        for (int i = 0; i < arr2.length; i++) {
            System.out.println(arr2[i]);
        }
    }

    /**
     *
     * @param arr 新数组
     * @param price 要判断是否重复的数据
     * @return
     */
    public static boolean contains(int[] arr, int price){
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == price){
                return true;
            }
        }
        return false;
    }
}
